<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>数据上报系统后台中心</title>

		<meta name="description" content="" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="/report/Public/assets/css/bootstrap.css" />
		<link rel="stylesheet" href="/report/Public/assets/css/font-awesome.css" />

		<!-- ace styles -->
		<link rel="stylesheet" href="/report/Public/assets/css/ace.css" class="ace-main-stylesheet" id="main-ace-style" />

		<!--[if lte IE 9]>
			<link rel="stylesheet" href="/report/Public/assets/css/ace-part2.css" class="ace-main-stylesheet" />
		<![endif]-->

		<!--[if lte IE 9]>
		  <link rel="stylesheet" href="/report/Public/assets/css/ace-ie.css" />
		<![endif]-->

		<!-- inline styles related to this page -->
        <link rel="stylesheet" href="/report/Public/assets/css/slackck.css" />
		<!-- ace settings handler -->
		<script src="/report/Public/assets/js/ace-extra.js"></script>
		<script src="/report/Public/assets/js/jquery.min.js"></script>
		<script src="/report/Public/assets/js/jquery.form.js"></script>
		<script src="/report/Public/layer/layer.js"></script>
		<!--<script src="/report/Public/assets/js/jquery.leanModal.min.js"></script>-->

		<!--[if lte IE 8]>
		<script src="/report/Public/assets/js/html5shiv.js"></script>
		<script src="/report/Public/assets/js/respond.js"></script>
		<![endif]-->
	</head>

	<body class="no-skin">
		<!-- #section:basics/navbar.layout -->
		<div id="navbar" class="navbar navbar-default navbar-collapse">
		<script type="text/javascript">

				try{ace.settings.check('navbar' , 'fixed')}catch(e){}

			</script>
			<div class="navbar-container" id="navbar-container">
			<button type="button" class="navbar-toggle menu-toggler pull-left" id="menu-toggler" data-target="#sidebar">

					<span class="sr-only">Toggle sidebar</span>



					<span class="icon-bar"></span>



					<span class="icon-bar"></span>



					<span class="icon-bar"></span>

				</button>
				<!-- /section:basics/sidebar.mobile.toggle -->
				<div class="navbar-header pull-left">
					<!-- #section:basics/navbar.layout.brand -->
					<a href="<?php echo U('Index/index');?>" class="navbar-brand">
						<small>
							<i class="fa fa-leaf"></i>
							数据上报系统后台中心
						</small>
					</a>

				</div>

				<!-- #section:basics/navbar.dropdown -->
				<div class="navbar-buttons navbar-header pull-right  collapse navbar-collapse" role="navigation">
					<ul class="nav ace-nav">
					<li class="transparent"></li>
					<li class="transparent">
						<a style="cursor:pointer;" id="cache" class="dropdown-toggle">清除缓存</a>
					</li>
			
						<!-- #section:basics/navbar.user_menu -->
						<li class="light-blue">
							<a data-toggle="dropdown" href="#" class="dropdown-toggle">
								<img class="nav-user-photo" src="/report/Public/assets/avatars/user.jpg" alt="Jason's Photo" />
								<span class="user-info">
									<small>Welcome,</small>
									<?php echo ($_SESSION['admin_username']); ?>
								</span>

								<i class="ace-icon fa fa-caret-down"></i>
							</a>

							<ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
<!--								<li>
									<a href="#">
										<i class="ace-icon fa fa-cog"></i>
										个人设置
									</a>
								</li>

								<li>
									<a href="profile.html">
										<i class="ace-icon fa fa-user"></i>
										会员中心
									</a>
								</li>

								<li class="divider"></li>-->

								<li>
									<a href="javascript:;"  id="logout">
										<i class="ace-icon fa fa-power-off"></i>
										注销
									</a>
								</li>
							</ul>
						</li>

						<!-- /section:basics/navbar.user_menu -->
					</ul>
				</div>

				<!-- /section:basics/navbar.dropdown -->
			</div><!-- /.navbar-container -->
		</div>


<script type="text/javascript">
$(document).ready(function(){
	$("#logout").click(function(){
		layer.confirm('你确定要退出吗？', {icon: 3}, function(index){
	    layer.close(index);
	    window.location.href="<?php echo U('Login/logout');?>";
	});
	});
});



$(function(){
$('#cache').click(function(){
if(confirm("确认要清除缓存？")){
var $type=$('#type').val();
var $mess=$('#mess');
$.post('/report/index.php/Admin/Table/clear',{type:$type},function(data){
alert("缓存清理成功");
});
}else{
return false;
}
});
});
</script>


<link rel="stylesheet" type="text/css" media="all" href="/report/Public/sldate/daterangepicker-bs3.css" />
<script type="text/javascript" src="/report/Public/sldate/moment.js"></script>
<script type="text/javascript" src="/report/Public/sldate/daterangepicker.js"></script>
<script src="/report/Public/My97DatePicker/WdatePicker.js"></script>
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">

    <!-- #section:basics/sidebar -->

    <div id="sidebar" class="sidebar responsive sidebar-fixed">

<!--	<div class="sidebar-shortcuts" id="sidebar-shortcuts">
		&lt;!&ndash;左侧顶端按钮&ndash;&gt;
		<div class="sidebar-shortcuts-large" id="sidebar-shortcuts-large">
			<a class="btn btn-success" href="#" role="button" title="文章列表"><i class="ace-icon fa fa-signal"></i></a>
			<a class="btn btn-info" href="#" role="button" title="添加文章"><i class="ace-icon fa fa-pencil"></i></a>
			<a class="btn btn-warning" href="#" role="button" title="会员列表"><i class="ace-icon fa fa-users"></i></a>
			<a class="btn btn-danger" href="#" role="button" title="站点设置"><i class="ace-icon fa fa-cogs"></i></a>
		</div>
        &lt;!&ndash;左侧顶端按钮（手机）&ndash;&gt;
		<div class="sidebar-shortcuts-mini" id="sidebar-shortcuts-mini">
			<a class="btn btn-success" href="#" role="button" title="文章列表"></a>
			<a class="btn btn-info" href="#" role="button" title="添加文章"></a>
			<a class="btn btn-warning" href="#" role="button" title="会员列表"></a>
			<a class="btn btn-danger" href="#" role="button" title="站点设置"></a>
		</div>
	</div>-->
    <!--菜单栏开始-->
	<ul class="nav nav-list">
		<?php use Common\Controller\AuthController; use Think\Auth; $m = M('auth_rule'); $field = 'id,name,title,css'; $data = $m->field($field)->where('pid=0 AND status=1 and menustatus=1')->order('sort')->select(); $auth = new Auth(); foreach ($data as $k=>$v){ if(!$auth->check($v['name'], $_SESSION['aid']) && $_SESSION['aid'] != 1){ unset($data[$k]); } } ?>
        <!--一级菜单遍历-->
		<?php if(is_array($data)): foreach($data as $key=>$v): ?><li class="<?php if(CONTROLLER_NAME == $v['name']): ?>open<?php endif; ?>">
			<a href="#" class="dropdown-toggle">
				<i class="menu-icon fa <?php echo ($v["css"]); ?>"></i>
							<span class="menu-text">
								<?php echo ($v["title"]); ?>
							</span>

				<b class="arrow fa fa-angle-down"></b>
			</a>
			<b class="arrow"></b>
			<ul class="submenu">
				<?php $m = M('auth_rule'); $dataa = $m->where(array('pid'=>$v['id'],'menustatus'=>1))->order('sort')->select(); foreach ($dataa as $kk=>$vv){ if(!$auth->check($vv['name'], $_SESSION['aid']) && $_SESSION['aid'] != 1){ unset($dataa[$kk]); } } $id_4=$m->where(array('name'=>CONTROLLER_NAME.'/'.ACTION_NAME,'level'=>4))->field('pid')->find(); if($id_4){ $id_3=$m->where(array('id'=>$id_4['pid'],'level'=>3))->field('pid')->find(); }else{ $id_3=$m->where(array('name'=>CONTROLLER_NAME.'/'.ACTION_NAME,'level'=>3))->field('pid')->find(); if(!$id_3){ $id_2=$m->where(array('name'=>CONTROLLER_NAME.'/'.ACTION_NAME,'level'=>2))->field('id')->find(); $id_3['pid']=$id_2['id']; } } ?>
                <!--二级菜单遍历-->
				<?php if(is_array($dataa)): foreach($dataa as $key=>$j): $m = M('auth_rule'); $dataaa = $m->where(array('pid'=>$j['id'],'status'=>1,'menustatus'=>1))->order('sort')->select(); foreach ($dataaa as $kkk=>$vvv){ if(!$auth->check($vvv['name'], $_SESSION['aid']) && $_SESSION['aid'] != 1){ unset($dataaa[$kkk]); } } ?>
					<?php if(empty($dataaa)): ?><!-- 无三级菜单 -->
					<li class="<?php if(($id_3['pid'] == $j['id'])): ?>active open<?php endif; ?>">
						<a href="<?php echo U($j['name']);?>">
							<i class="menu-icon fa fa-caret-right"></i>
							<?php echo ($j["title"]); ?>
						</a>
						<b class="arrow"></b>
					</li>
					<?php else: ?>
					<li class="<?php if(($id_3['pid'] == $j['id'])): ?>active open<?php endif; ?>">
						<a href="#" class="dropdown-toggle">
							<i class="menu-icon fa fa-caret-right"></i>
							<?php echo ($j["title"]); ?>
							<b class="arrow fa fa-angle-down"></b>
						</a>
						<b class="arrow"></b>
						<ul class="submenu">
							<!--三级菜单遍历-->
							 <?php if(is_array($dataaa)): foreach($dataaa as $key=>$m): ?><li class="<?php if(((CONTROLLER_NAME.'/'.ACTION_NAME) == $m['name'])): ?>active<?php endif; ?>">
								<a href="<?php echo U($m['name']);?>">
									<i class="menu-icon fa fa-leaf green"></i>
									<?php echo ($m["title"]); ?>
								</a>
								<b class="arrow"></b>
								</li><?php endforeach; endif; ?>
							<!--三级菜单遍历结束-->
						</ul>
					</li><?php endif; endforeach; endif; ?>
                <!--二级菜单遍历结束-->
			</ul>
			</li><?php endforeach; endif; ?>
        <!--一级菜单遍历结束-->
	</ul><!-- 菜单栏结束 -->

	<!-- 左侧菜单伸缩 -->
	<div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">
		<i class="ace-icon fa fa-angle-double-left" data-icon1="ace-icon fa fa-angle-double-left" data-icon2="ace-icon fa fa-angle-double-right"></i>
	</div>
	<script type="text/javascript">
		try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
	</script>
</div>

    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">

                <!--主题-->
                <div class="page-header">
                    <h1>
                        您当前操作
                        <small>
                            <i class="ace-icon fa fa-angle-double-right"></i>
                            下发报表
                        </small>
                    </h1>
                </div>





                <div class="row">
                    <div class="col-xs-12">
                        <div>
                            <form class="form-horizontal" name="form1" id="form1" method="post" action="<?php echo U('send_table_run');?>">
                                <div class="form-group">
                                    <label class="col-sm-5 control-label no-padding-right" for="form-field-1">选择报表：  </label>
                                    <div class="col-sm-3">
                                        <select name="tableid" id="tableid">
                                            <option value="">--选择报表--</option>
                                            <?php if(is_array($type)): foreach($type as $key=>$v): ?><option value="<?php echo ($v["id"]); ?>"><?php echo ($v["title"]); ?></option><?php endforeach; endif; ?>
                                        </select>

                                    </div>
                                </div>
                                <div class="space-4"></div>

                                <div class="form-group">
                                    <label class="col-sm-5 control-label no-padding-right" for="form-field-1">报表年份：  </label>
                                    <div class="col-sm-3">
                                            <select id="year" name="year">
                                                <option value="0">请选择年份</option>
                                                <?php if(is_array($year)): $i = 0; $__LIST__ = $year;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><option value="<?php echo ($v); ?>"><?php echo ($v); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                                            </select>
                                    </div>

                                </div>
                                <div class="space-4"></div>

                                <div class="form-group">
                                    <label class="col-sm-5 control-label no-padding-right" for="form-field-1">报表季度：  </label>
                                    <div class="col-sm-3">
                                        
                                        <select id="quarter" name="quarter">
                                            <option value="0">请选择季度</option>
                                            <option value="1">1</option>
                                            <option value="2">2</option>
                                            <option value="3">3</option>
                                            <option value="4">4</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="space-4"></div>

                                <div class="form-group">
                                    <label class="col-sm-5 control-label no-padding-right" for="form-field-1">报表有效期：  </label>
                                    <div class="col-sm-3">
                                        <input type="text" style="display: inline-block;" class="Wdate" id="endtime" name="endtime" onFocus="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd HH:mm:ss'})" placeholder="请点击选择有效期" />
                                    </div>
                                </div>
                                <div class="space-4"></div>

                                <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">


                                    <tr>
                                        <td height="30"  style="border-bottom:#CCCCCC solid 1px; line-height:25px; background-color:#F4F8FB">
                                            <label>
                                                <input type="checkbox" class="ace ace-checkbox-2"  id='chkAll' onclick='CheckAll(this.form)' value="全选"/>
                                                <span class="lbl"> 企业全选</span>
                                            </label>
                                            <label style="margin: 0 19%;">
                                                <input style="height: 25px;" id="company_text" type="text" placeholder="请输入查询的公司标题" value="">
                                                <button type="button" id="ajax_c">搜索</button>
                                            </label>
                                            <label style="float: right;">按分类筛选企业: &nbsp;&nbsp;&nbsp;&nbsp;
                                                    <select id="company_type">
                                                        <option value="">---选择筛选企业分类---</option>
                                                        <option value="1">港区规模以上贸易业</option>
                                                        <option value="2">港区物流专业市场</option>
                                                        <option value="3">临港规模以上工业</option>
                                                        <option value="4">港区运输企业</option>
                                                        <option value="5">港区仓储配送企业</option>
                                                        <option value="6">其他</option>
                                                    </select>
                                                &nbsp;&nbsp;
                                            </label>
                                        </td>


                                    </tr>
                                    <tr>


                                            <td class="company_info" height="30" style="padding-left:70px;border-bottom:#E7EBF8 dashed 1px; color:#666666">

                                                <?php if(is_array($company)): $i = 0; $__LIST__ = $company;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><label class="thopen">
                                                        <input name="sendid[]" class="ace ace-checkbox-2 checkbox-child" type="checkbox"  id="<?php echo ($vo["comid"]); ?>" value="<?php echo ($vo["comid"]); ?>"  />
                                                    <span class="lbl" style="margin-right:10px;"><?php echo ($vo["name"]); ?></span>
                                                    </label><?php endforeach; endif; else: echo "" ;endif; ?>

                                            </td>


                                    </tr>

                                </table>



                                <div class="clearfix form-actions">
                                    <div class="col-md-offset-5 col-md-9">
                                        <button class="btn btn-info" type="submit">
                                            <i class="ace-icon fa fa-check bigger-110"></i>
                                            下发
                                        </button>

                                        &nbsp; &nbsp; &nbsp;
                                        <button class="btn" type="reset">
                                            <i class="ace-icon fa fa-undo bigger-110"></i>
                                            重置
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

                <div class="breadcrumbs breadcrumbs-fixed " id="breadcrumbs">
	<div class="row">
		<div class="col-xs-12">
			<div class="">
				<div id="sidebar2" class="sidebar h-sidebar navbar-collapse collapse collapse_btn">
					<ul class="nav nav-list header-nav" id="header-nav">
						<?php $m = M('auth_rule'); $dataaa = $m->where(array('pid'=>$id_3['pid'],'status'=>1,'menustatus'=>1))->order('sort')->select(); foreach ($dataaa as $kkk=>$vvv){ if(!$auth->check($vvv['name'], $_SESSION['aid']) && $_SESSION['aid']!= 1){ unset($dataaa[$kkk]); } } if(empty($dataaa)){ $dataaa = $m->where(array('id'=>$id_3['pid']))->order('sort')->find(); $dataaa = $m->where(array('pid'=>$dataaa['pid'],'status'=>1))->order('sort')->select(); if(!$auth->check($vvv['name'], $_SESSION['aid']) && $_SESSION['aid']!= 1){ unset($dataaa[$kkk]); } } ?>
    					<?php if(is_array($dataaa)): foreach($dataaa as $key=>$k): ?><li>
										<a href="<?php echo U(''.$k['name'].'');?>">
											<o class="font12 <?php if((CONTROLLER_NAME.'/'.ACTION_NAME == $k['name'])): ?>rigbg<?php endif; ?>"><?php echo ($k["title"]); ?></o>
										</a>

								<b class="arrow"></b>
							</li><?php endforeach; endif; ?>
					</ul><!-- /.nav-list -->
				</div><!-- .sidebar -->
			</div>
		</div><!-- /.col -->
	</div><!-- /.row -->
	
</div>

            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->


    <script>
        var app = '/report/index.php';
        function CheckAll(form){
            for (var i=0;i<form.elements.length;i++){
                var e = form.elements[i];
                if (e.Name != 'chkAll'&&e.disabled==false)
                    e.checked = form.chkAll.checked;
            }
        }

        $(function(){
            $("#ajax_c").click(function () {
                var text = $('#company_text').val();
                $.ajax({
                    type : 'post',
                    data : {text:text},
                    dataType : 'json',
                    url : app+'/Admin/table/company_ajax',
                    success : function(res){
                        $('.company_info').empty();
                        var htmls = '';
                        if (res != ''){
                            $.each(res,function (item,value) {
                                htmls +='<label class="thopen">';
                                htmls +='<input name="sendid[]" class="ace ace-checkbox-2 checkbox-child" type="checkbox"  id="'+value.comid+'" value="'+value.comid+'" />';
                                htmls +='<span class="lbl" style="margin-right:10px;">'+value.name+'</span>';
                                htmls +='</label>';
                            })
                            console.log(htmls);
                        }else {
                            htmls = '<p style="text-align: center">暂无企业</p>'
                        }

                        $('.company_info').append(htmls);
                    }
                });
            });

            $('#company_type').change(function () {
                if($(this).val() != ''){
                    $.ajax({
                        type : 'post',
                        data : {id:$(this).val()},
                        dataType : 'json',
                        url : app+'/Admin/table/type_ajax',
                        success : function(res){
                            $('.company_info').empty();
                            var htmls = '';
                            if (res != ''){
                                $.each(res,function (item,value) {
                                    htmls +='<label class="thopen">';
                                    htmls +='<input name="sendid[]" class="ace ace-checkbox-2 checkbox-child" type="checkbox"  id="'+value.comid+'" value="'+value.comid+'" />';
                                    htmls +='<span class="lbl" style="margin-right:10px;">'+value.name+'</span>';
                                    htmls +='</label>';
                                })
                                console.log(htmls);
                            }else {
                                htmls = '<p style="text-align: center">暂无企业</p>'
                            }

                            $('.company_info').append(htmls);
                        }
                    });
                }
            });

            $('#form1').ajaxForm({
                beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
                success: complete, // 这是提交后的方法
                dataType: 'json'
            });

            function checkForm(){

                if( '' == $.trim($('#tableid option:selected').val())){
                    layer.alert('请选择报表', {icon: 6}, function(index){
                        layer.close(index);
                        $('#tableid').focus();
                    });
                    return false;
                }


                if( '0' == $.trim($('#year option:selected').val())){
                    layer.alert('请选择报表年份', {icon: 6}, function(index){
                        layer.close(index);
                        $('#year').focus();
                    });
                    return false;
                }
                //正则判断年份格式是否正确
                var reDateTime = /^(?:19|20)[0-9][0-9]$/;
                
                var isDateTime = reDateTime.test($.trim($('#year option:selected').val()));
                if (isDateTime == false){
                    layer.alert('报表年份格式有误', {icon: 6}, function(index){
                        layer.close(index);
                        $('#year').focus();
                    });
                    return false;
                }


                if('0' == $.trim($('#quarter option:selected').val())){
                    layer.alert('请选择报表季度', {icon: 6}, function(index){
                        layer.close(index);
                        $('#quarter').focus();
                    });
                    return false;
                }
                var quarter1 = $.trim($('#quarter option:selected').val());
                var arr = new Array("1","2","3","4");
                var isquarter = $.inArray(quarter1,arr);
                if(isquarter == -1){
                    layer.alert('报表季度格式有误', {icon: 6}, function(index){
                        layer.close(index);
                        $('#quarter').focus();
                    });
                    return false;
                }

                if(''== $.trim($('#endtime').val())){
                    layer.alert('请选择报表有效期时间', {icon: 6}, function(index){
                        layer.close(index);
                        $('#endtime').focus();
                    });
                    return false;
                }
                if($("input:checkbox[name='sendid[]']:checked").length == 0){
                    layer.alert('请至少选中一个下发企业', {icon: 6}, function(index){
                        layer.close(index);
                        $('.company_info').focus();
                    });
                    return false;
                }

            }
            function complete(data){
                if(data.status==1){
                    layer.alert(data.info, {icon: 6}, function(index){
                        layer.close(index);
                        window.location.href=data.url;
                    });
                }else{
                    layer.alert(data.info, {icon: 6}, function(index){
                        layer.close(index);
                    });
                    return false;
                }
            }

        });
    </script>
    			<div class="footer">
				<div class="footer-inner">
					<!-- #section:basics/footer -->
					<div class="footer-content">
						<span class="bigger-120">
							<span class="blue bolder">成信大创新创业教育</span>
							后台管理系统 &copy; 2015-2016
						</span>
					</div>

					<!-- /section:basics/footer -->
				</div>
			</div>
            

		<!-- basic scripts -->


<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='../assets/js/jquery1x.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<script src="/report/Public/assets/js/bootstrap.js"></script>
		<script src="/report/Public/assets/js/maxlength.js"></script>
		<script src="/report/Public/assets/js/ace/ace.js"></script>
		<script src="/report/Public/assets/js/ace/ace.sidebar.js"></script>


		<!-- inline scripts related to this page -->
		<script type="text/javascript">
			jQuery(function($) {
			   $('#sidebar2').insertBefore('.page-content');
			   
			   $('.navbar-toggle[data-target="#sidebar2"]').insertAfter('#menu-toggler');
			   
			   
			   $(document).on('settings.ace.two_menu', function(e, event_name, event_val) {
				 if(event_name == 'sidebar_fixed') {
					 if( $('#sidebar').hasClass('sidebar-fixed') ) {
						$('#sidebar2').addClass('sidebar-fixed');
						$('#navbar').addClass('h-navbar');
					 }
					 else {
						$('#sidebar2').removeClass('sidebar-fixed')
						$('#navbar').removeClass('h-navbar');
					 }
				 }
			   }).triggerHandler('settings.ace.two_menu', ['sidebar_fixed' ,$('#sidebar').hasClass('sidebar-fixed')]);
			})
		</script>


</div><!-- /.main-container -->
</body>
</html>